﻿<CascadingAuthenticationState>
    <Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="Assemblies">
        <Found Context="routeData">
            <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
                <NotAuthorized>
                    <div class="alert alert-danger">请联系管理员</div>
                </NotAuthorized>   
            </AuthorizeRouteView>
            <FocusOnNavigate RouteData="@routeData" Selector="h1" />
        </Found>
        <NotFound>
            <PageTitle>Not found</PageTitle>
            <LayoutView Layout="@typeof(MainLayout)">
                <p role="alert">Sorry, there's nothing at this address.</p>
            </LayoutView>
        </NotFound>
    </Router>
</CascadingAuthenticationState>

@using System.Reflection

@code{
    IEnumerable<Assembly> Assemblies{
        get
        {
            var dll= Directory.EnumerateFiles(AppDomain.CurrentDomain.BaseDirectory, "BlazorLearn.*.dll", SearchOption.AllDirectories).Distinct()
            .Take(1);

            foreach (var item in dll)
            {
                yield return Assembly.LoadFile(item);
            }
        } 
    }
}